package com.finger.forest.model;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * @author sy
 * @date 2020/6/7
 * @desc
 */
public class BaseModel<T> implements Parcelable {
    private int code;
    private String msg;
    private T rst;

    public BaseModel(){

    }

    protected BaseModel(Parcel in) {
        code = in.readInt();
        msg = in.readString();
    }

    public static final Creator<BaseModel> CREATOR = new Creator<BaseModel>() {
        @Override
        public BaseModel createFromParcel(Parcel in) {
            return new BaseModel(in);
        }

        @Override
        public BaseModel[] newArray(int size) {
            return new BaseModel[size];
        }
    };

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getRst() {
        return rst;
    }

    public void setRst(T rst) {
        this.rst = rst;
    }

    @Override
    public int describeContents() {
        return BaseModel.this.hashCode();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(code);
        dest.writeString(msg);
    }
}
